export interface Execution {
  id: string
  script_id?: string
  connection_id: string
  sql: string
  status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'
  start_time: string
  end_time?: string
  duration?: number
  rows_affected?: number
  rows_returned?: number
  error_message?: string
  result_data?: any
  created_by: string
  created_at: string
  updated_at: string
}

export interface ExecutionResult {
  query_id: string
  columns: Array<{
    name: string
    type: string
    nullable?: boolean
  }>
  rows: any[][]
  total_rows: number
  affected_rows?: number
  execution_time: number
  explain_plan?: string
}

export interface ExecutionStatus {
  id: string
  status: 'pending' | 'running' | 'completed' | 'failed' | 'cancelled'
  progress?: number
  message?: string
  start_time?: string
  end_time?: string
  duration?: number
  error?: string
  stages?: Array<{
    name: string
    status: 'pending' | 'running' | 'completed' | 'failed'
    start_time?: string
    end_time?: string
    duration?: number
    message?: string
  }>
}

export interface ExecutionOptions {
  connectionId: string
  sql: string
  limit?: number
  timeout?: number
  autoCommit?: boolean
  explainOnly?: boolean
}

export interface ExecutionHistoryItem {
  id: string
  sql: string
  connection_name: string
  connection_id: string
  status: 'completed' | 'failed' | 'cancelled'
  start_time: string
  end_time?: string
  duration: number
  rows_affected?: number
  rows_returned?: number
  error_message?: string
  created_by: string
}

export interface ExecutionStats {
  total_executions: number
  successful_executions: number
  failed_executions: number
  average_duration: number
  total_duration: number
  most_used_connections: Array<{
    connection_id: string
    connection_name: string
    count: number
  }>
  execution_trends: Array<{
    date: string
    count: number
    avg_duration: number
  }>
}